# 申请请假业务
import time

from base.imp.base import base_imp, bases_imp
from selenium.webdriver.common.by import By

# 定于对象层
class Pubash_page(base_imp):
    def __init__(self):
        super().__init__()
        # 定位请假调休元素
        self.hepay = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[2]/div[2]/div[1]/div/div[2]/ul/li[2]/a'
        # 定位假期类型
        self.jqlx = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[2]/span/div[2]/form/div[1]/div/div/div/input'
        # 定位选择请假选项(这里需要传递元组，所以加上括号)
        #self.qj = (By.XPATH, '/html/body/div[5]/div[1]/div[1]/ul/li[1]')
        # 定位选择开始日期
        self.star = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[2]/span/div[2]/form/div[3]/div/div/div/input'
        # 定位选择此刻
        self.ck = By.XPATH, '/html/body/div[7]/div[2]/button[1]/span'
        # 定位结束日期
        self.js = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[2]/span/div[2]/form/div[4]/div/div/div/input'
        # 定位选择此刻
        self.cks = By.XPATH, '/html/body/div[7]/div[2]/button[1]'
        # 定位请假时长
        self.Sc = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[2]/span/div[2]/form/div[5]/div/div/input'
        # 定位申请理由
        self.ly = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[2]/span/div[2]/form/div[6]/div/div/textarea'
        #定位提交
        self.tj = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[2]/span/div[2]/form/div[7]/div/button[1]/span'
        # 定位关闭
        #self.out = By.XPATH, '//*[@id="app"]/div/div[2]/section/div/div[3]/div/div[1]/button/i'
    # 封装定位元素
    def click_hepay(self):
        return self.get_element(self.hepay)
    def get_jqlx(self):
        return self.get_element(self.jqlx)
    #def click_qj(self):
     #   return self.exec_element(self.qj)
    def get_star(self):
        return self.get_element(self.star)
    #def click_ck(self):
     #   return self.exec_element(self.ck)
    def get_js(self):
        return self.get_element(self.js)
    #def click_cks(self):
     #   return self.get_element(self.cks)
    def get_Sc(self):
        return self.get_element(self.Sc)
    def get_ly(self):
        return self.get_element(self.ly)
    def click_tj(self):
        return self.get_element(self.tj)
    #def click_out(self):
        #return self.get_element(self.out)
# 定义操作层
class Pubash_imp(bases_imp):
    def __init__(self):
        self.pubash_page = Pubash_page()
    # 点击请假
    def imp_hepay(self):
        self.pubash_page.click_hepay().click()
    # 点击请假类型
    def imp_jqlx(self):
        self.pubash_page.get_jqlx().click()
    # 选择请假类型
    def imp_qj(self):
        self.imp_stas(self.pubash_page.get_jqlx())
    # 点击开始时间
    def imp_star(self):
        self.pubash_page.get_star().click()
    # 点击此刻为开始时间
    def imp_ck(self):
        self.imp_stas(self.pubash_page.get_star())
    # 选择结束时间
    def imp_js(self):
        self.pubash_page.get_js().click()
    # 点击此刻为开始时间
    def imp_cks(self):
        self.imp_stass(self.pubash_page.get_js())
    # 输入请假时长
    def imp_Sc(self, sc):
        self.imp_sta(self.pubash_page.get_Sc(), sc)
    # 输入请假理由
    def imp_ly(self, ly):
        self.imp_sta(self.pubash_page.get_ly(), ly)
    # 点击提交
    def imp_tj(self):
        self.pubash_page.click_tj().click()
    # 点击关闭
    #def imp_out(self):
        #self.pubash_page.click_out().click()

# 定义业务层
class pubash_sta:
    def __init__(self):
        self.pubash_imp = Pubash_imp()
    # 进行请假流程申请
    def start_pubash(self, sc, ly):
        self.pubash_imp.imp_hepay()
        time.sleep(2)
        self.pubash_imp.imp_jqlx()
        time.sleep(2)
        self.pubash_imp.imp_qj()
        time.sleep(2)
        self.pubash_imp.imp_star()
        time.sleep(2)
        self.pubash_imp.imp_ck()
        time.sleep(2)
        self.pubash_imp.imp_js()
        time.sleep(2)
        self.pubash_imp.imp_cks()
        time.sleep(2)
        self.pubash_imp.imp_Sc(sc)
        time.sleep(2)
        self.pubash_imp.imp_ly(ly)
        time.sleep(2)
        self.pubash_imp.imp_tj()
        time.sleep(5)
        # self.pubash_imp.imp_out()